#!/bin/bash
# 前提：需要安装好JDK

version="3.7.0"
mkdir -p cd /data/tools
cd /data/tools
echo 'downloading...'
wget -c https://mirrors.huaweicloud.com/apache/zookeeper/zookeeper-${version}/apache-zookeeper-${version}-bin.tar.gz || exit 1

tar zxvf apache-zookeeper-${version}-bin.tar.gz

ln -s apache-zookeeper-${version}-bin zookeeper

mkdir -p /data/data/zookeeper

cat >/data/tools/zookeeper/conf/zoo.cfg <<EOF
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/data/zookeeper
clientPort=2181
autopurge.snapRetainCount=3
autopurge.purgeInterval=1
#server.1=localhost:2287:3387 
#server.2=localhost:2288:3388 
#server.3=localhost:2289:3389
EOF

sh /data/tools/zookeeper/bin/zkServer.sh start /data/tools/zookeeper/conf/zoo.cfg